

import { defineNuxtPlugin } from '#app';

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.directive('auth', {
    mounted(el, binding) {
      const auth = useUserStore()

      // 未登录情况下，内容隐藏或删除
      if (!auth.isLoggedIn) {
        if (binding.arg == 'hide') {
          el.style.display = 'none'
        } else if(binding.arg == 'initNum'){
          el.textContent = 0
        } else {
          el.remove()
        }
      }
    },
  })
})
